"""
@作者 = "陈诗"
@email = 3168157154@qq.com
@creative_time = 2025/10/31 15:53
"""
from Hero import Hero
from Monster import Monster
import random as rd

hero1 = Hero("英雄1", 100)  # 录入英雄
monster1 = Monster("小怪a", 150)  # 录入怪物
# 录入hero技能
hero1.skill('平A', 10)
hero1.skill('大招', 25)
# 录入monster技能
monster1.skill('撕咬', 25)
monster1.skill('爪击', 15)


while hero1.alive() and monster1.alive():  # 循环攻击 同时存活
    skillname1 = rd.choice(list(hero1.skills.keys()))  # 随机技能
    skillname2 = rd.choice(list(monster1.skills.keys()))
    print(f"{hero1.name} HP:{hero1.hp}  {monster1.name} HP:{monster1.hp}")  # 显示双方血量
    hero1.attack(skillname1, monster1)
    if monster1.alive() is True:  # 布尔值判断,怪活着则反击
        monster1.attack(skillname2, hero1)
        if hero1.alive() is False:
            print(f"{hero1.name}被{monster1.name}杀死!")
            break
        else:
            print(f"{hero1.name}剩余血量: {hero1.hp}   {monster1.name}剩余血量: {monster1.hp}")  # 英雄活着,显示双方血量,进行下一回合
            continue
    else:
        print(f"{monster1.name}被{hero1.name}杀死!")
        break
